import { clientJoinedChannels } from '../../lib/collections';

Template.home_channels_joined.onCreated(function() {
  this.infiniteScroll({
    query: {
      user_id: Meteor.userId()
    },
    publication: 'get.joined.channels',
    countPublication: 'get.joined.channels.counts'
  });
});

Template.home_channels_joined.helpers({
  results: function() {
    return clientJoinedChannels.find({}, {
      limit: Template.instance().getLimit(),
      sort: {
        createdAt: -1
      }
    });
  },

  loading: function() {
    return !Template.instance().resultSub.ready();
  }
});